Simplify and build-fix (for some gcc versions) radix_tree_int_to_ptr().
authorKeir Fraser <keir@xen.org>
Wed, 11 May 2011 11:58:04 +0000 (12:58 +0100)
committerKeir Fraser <keir@xen.org>
Wed, 11 May 2011 11:58:04 +0000 (12:58 +0100)
Signed-off-by: Keir Fraser <keir@xen.org>
xen/include/xen/radix-tree.h

index 54fd7c1477f9bc48795e05121ab31641fa77920d..15d88a2844ccafb6c2911254edf788d1802439a6 100644 (file)
@@ -181,8 +181,9 @@ static inline void radix_tree_replace_slot(void **pslot, void *item)
  */
 static inline void *radix_tree_int_to_ptr(int val)
 {
-    ASSERT((val <= (LONG_MAX >> 2)) && (val >= (LONG_MIN >> 2)));
-    return (void *)(((long)val << 2) | 0x2ul);
+    long _ptr = ((long)val << 2) | 0x2l;
+    ASSERT((_ptr >> 2) == val);
+    return (void *)_ptr;
 }
 
 static inline int radix_tree_ptr_to_int(void *ptr)